package com.exm.collectcodenew.activemq.boot.produce;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import javax.jms.Queue;
import java.util.UUID;

@Service
public class Queue_produce {
    @Autowired
    private JmsMessagingTemplate jmsMessagingTemplate;
    @Autowired
    private Queue queue;
    public void produceMsg(){
        jmsMessagingTemplate.convertAndSend( queue,"*****schedule:"+ UUID.randomUUID().toString().substring(0,6));
    }
    //间隔时间3秒钟定投
    @Scheduled(fixedDelay = 3000)
    public void produceMsgScheduled(){
        jmsMessagingTemplate.convertAndSend( queue,"*****schedule:"+ UUID.randomUUID().toString().substring(0,6));
    }
}
